package com.emspost;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import com.emspost.utils.DateUtil;
import org.apache.shiro.SecurityUtils;

import java.nio.charset.StandardCharsets;
import java.security.Security;

public class AesTest {

    public static void main(String[] args) {
        String uuid = IdUtil.simpleUUID();
        System.out.println("随机字符串:" + StrUtil.sub(uuid, 0, 16));


        String phoneNumber = "7c810044b4cb93cdbd53f42a8aa9042f";
        String phone = "13400000000";
        String secretKey = "e8fd54d774df407f";

        String encryptHex = SecureUtil.aes(secretKey.getBytes(StandardCharsets.UTF_8)).encryptHex(phone);

        String decryptStr = SecureUtil.aes(secretKey.getBytes(StandardCharsets.UTF_8)).decryptStr(phoneNumber);
        System.out.println("加密字符串" + encryptHex);
        System.out.println("解密字符串" + decryptStr);


        AES aes = new AES("ECB", "PKCS7Padding",
                // 密钥，可以自定义
                secretKey.getBytes(StandardCharsets.UTF_8));
        System.out.println(aes.encryptHex("13400000000"));
        System.out.println(aes.decryptStr("7c810044b4cb93cdbd53f42a8aa9042f"));
//        System.out.println(aes.decryptStr("d41d8cd98f00b204e9800998ecf8427e"));


        System.out.println(DateUtil.getStrDate(-2));
        System.out.println(DateUtil.getStrDate(-1));


    }
}
